﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
using Stimulsoft.Report;
using Portal.Web.Global;
using Portal.Web.Framework;
using Portal.AssetTn.Model;
using Portal.Core;


namespace Portal.Gui.Web.WebParts.AssetTn
{
    public class AssetTN_PrintInventory : WebPart
    {
        public override string WebPartId
        {
            get
            {
                return "AssetTN.PrintInventory";
            }
        }


        public override WebPartServiceCls WebPartService
        {
            get
            {
                return AssetUtility.WebPartService;
            }
        }

        public override string Title
        {
            get
            {
                return "In sổ kiểm kê bước đầu";
            }
        }

        public override string Description
        {
            get
            {
                return "";
            }
        }


        public override string RenderWebPart(LoadParamCls loadParamCls)
        {
            try
            {
                string SiteId = loadParamCls.SiteId;
                Environments.CheckSessionTimeOut(true);
                Permission.CheckPermission(
                     SiteId,
                     Environments.CurrentLoginUser.LoginName,
                     Portal.AssetTn.Security.Permission.GetPermissionId(),
                     Portal.AssetTn.Security.Permission.ePermisionType.Portal_AssetTn_Main.ToString(),
                     Portal.AssetTn.Security.Permission.eFunction.Portal_AssetTn_Report.ToString(),
                     Portal.AssetTn.Security.Permission.GetPermissionId(),
                     null,
                     true);

                bool VisibleSearchForm = true;
                string SessionId = (string)Environments.Request("SessionId");
                if (string.IsNullOrEmpty(SessionId))
                {
                    SessionId = System.Guid.NewGuid().ToString();
                }
                else
                {
                    VisibleSearchForm = false;
                }
                
                string Subject = loadParamCls.RefTitle;
                if (string.IsNullOrEmpty(Subject))
                {
                    Subject = Title;
                }

                
                string RetHtml = AssetRenderPrintBll.Render(SessionId, "print", WebPartId, SiteId, "other", "Điều kiện in sổ kiểm kê", "print_large.png", "so-kiem-ke-buoc-dau.mrt", false, VisibleSearchForm);
                return RetHtml;
            }
            catch (Exception ex)
            {
                return ex.Message.ToString();
            }
        }

      
        public override void RegAjaxPro(System.Web.UI.Page ActivePage)
        {
            AjaxPro.Utility.RegisterTypeForAjax(typeof(AssetTN_PrintInventory));
            AjaxPro.Utility.RegisterTypeForAjax(typeof(AssetRenderPrintBll));
        }
    }
}
